import java.util.Collection;
import java.util.Collections;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Leetcode1742 {
    public int countBalls(int lowLimit, int highLimit) {
        int[] count = new int[46];
        int max = 0;
        while (lowLimit <= highLimit) {
            int sum = 0;

            int current = lowLimit;
            while (current != 0) {
                sum += current % 10;
                current /= 10;
            }

            count[sum]++;
            if (count[sum] > max) {
                max = count[sum];
            }
            lowLimit++;
        }

        return max;
    }

}
